//
//  UIScrollViewExtension.swift
//  QianPing
//
//  Created by yanglipeng on 2019/1/18.
//  Copyright © 2019 yanglipeng. All rights reserved.
//

import UIKit
import SnapKit
extension UIScrollView {
    
    /// 水平布局
    ///
    /// - Parameter subviews: 子view
    func snpHorizontalSubviews<T: UIView>(_ subviews: [T]) {
        
        for (index, view) in subviews.enumerated() {
            view.snp.remakeConstraints { (make) in
                make.top.height.bottom.equalToSuperview()
                
                make.width.equalToSuperview()
                if index == 0 {
                    make.left.equalToSuperview()
                } else {
                    make.left.equalTo(subviews[index - 1].snp.right)
                }
                if index == subviews.count - 1 {
                    make.right.equalToSuperview()
                }
            }
        }
        
    }
}
